<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
<link href="//cdn.bootcss.com/pace/1.0.2/themes/pink/pace-theme-flash.css" rel="stylesheet">





<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="链表面试题,编程之美,无头单链表," />










<meta name="description" content="写在前面 对于不带头结点的单链表操作，是在面试中经常出现的，在此对于常见链表操作进行总结，操作：有序链表合并、链表反转、链表排序、找倒数第K个节点、非头节点前插入data、删除非尾节点、约瑟夫环、带环链表环的大小等等">
<meta name="keywords" content="链表面试题,编程之美,无头单链表">
<meta property="og:type" content="article">
<meta property="og:title" content="【编程之美】链表面试题汇总版">
<meta property="og:url" content="http://yoursite.com/2018/06/21/【编程之美】链表面试题汇总版/index.html">
<meta property="og:site_name" content="Askunix&#39;s Blog">
<meta property="og:description" content="写在前面 对于不带头结点的单链表操作，是在面试中经常出现的，在此对于常见链表操作进行总结，操作：有序链表合并、链表反转、链表排序、找倒数第K个节点、非头节点前插入data、删除非尾节点、约瑟夫环、带环链表环的大小等等">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-06-23T07:31:37.703Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="【编程之美】链表面试题汇总版">
<meta name="twitter:description" content="写在前面 对于不带头结点的单链表操作，是在面试中经常出现的，在此对于常见链表操作进行总结，操作：有序链表合并、链表反转、链表排序、找倒数第K个节点、非头节点前插入data、删除非尾节点、约瑟夫环、带环链表环的大小等等">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2018/06/21/【编程之美】链表面试题汇总版/"/>





<script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
<link href="//cdn.bootcss.com/pace/1.0.2/themes/pink/pace-theme-flash.css" rel="stylesheet">



<script>
    (function(){
        if(''){
            if (prompt('请输入文章密码') !== ''){
                alert('密码错误！');
                history.back();
            }
        }
    })();
</script>










  <script>
  (function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/0f81ff2f.js","daovoice")
  daovoice('init', {
      app_id: "8c28bdbe"
    });
  daovoice('update');
  </script>










  <title>【编程之美】链表面试题汇总版 | Askunix's Blog</title>
  
  
  
  <head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
<link href="//cdn.bootcss.com/pace/1.0.2/themes/pink/pace-theme-flash.css" rel="stylesheet">





<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="链表面试题,编程之美,无头单链表," />










<meta name="description" content="写在前面 对于不带头结点的单链表操作，是在面试中经常出现的，在此对于常见链表操作进行总结，操作：有序链表合并、链表反转、链表排序、找倒数第K个节点、非头节点前插入data、删除非尾节点、约瑟夫环、带环链表环的大小等等">
<meta name="keywords" content="链表面试题,编程之美,无头单链表">
<meta property="og:type" content="article">
<meta property="og:title" content="【编程之美】链表面试题汇总版">
<meta property="og:url" content="http://yoursite.com/2018/06/21/【编程之美】链表面试题汇总版/index.html">
<meta property="og:site_name" content="Askunix&#39;s Blog">
<meta property="og:description" content="写在前面 对于不带头结点的单链表操作，是在面试中经常出现的，在此对于常见链表操作进行总结，操作：有序链表合并、链表反转、链表排序、找倒数第K个节点、非头节点前插入data、删除非尾节点、约瑟夫环、带环链表环的大小等等">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-06-23T07:31:37.703Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="【编程之美】链表面试题汇总版">
<meta name="twitter:description" content="写在前面 对于不带头结点的单链表操作，是在面试中经常出现的，在此对于常见链表操作进行总结，操作：有序链表合并、链表反转、链表排序、找倒数第K个节点、非头节点前插入data、删除非尾节点、约瑟夫环、带环链表环的大小等等">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2018/06/21/【编程之美】链表面试题汇总版/"/>





<script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
<link href="//cdn.bootcss.com/pace/1.0.2/themes/pink/pace-theme-flash.css" rel="stylesheet">



<script>
    (function(){
        if(''){
            if (prompt('请输入文章密码') !== ''){
                alert('密码错误！');
                history.back();
            }
        }
    })();
</script>










  <script>
  (function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/0f81ff2f.js","daovoice")
  daovoice('init', {
      app_id: "8c28bdbe"
    });
  daovoice('update');
  </script>










  <title>【编程之美】链表面试题汇总版 | Askunix's Blog</title>
  <style>
  .forkme{
 display: none;
 }
  @media (min-width: 768px) {
 .forkme{
 display: inline;
 }
  }
  </style>
</head>


  
  
  
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?e788bb7bb12bdeb68dc9923dc5b7a69a";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

	
	
	
	
	
<a href="https://github.com/askunix" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#64CEAA; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
	
	
	
	
	
	
	
	
	
	
	
	
	
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Askunix's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">不积跬步无以至千里</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            博客首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于作者
          </a>
        </li>
      
        
        <li class="menu-item menu-item-photo">
          <a href="/photo/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-camera-retro"></i> <br />
            
            相册分享
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签速查
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            文章分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档记录
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/06/21/【编程之美】链表面试题汇总版/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="何进鸿">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://7xrvas.com1.z0.glb.clouddn.com/16-4-6/38502140.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Askunix's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">【编程之美】链表面试题汇总版</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-06-21T17:49:33+08:00">
                2018-06-21
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/编程之美/" itemprop="url" rel="index">
                    <span itemprop="name">编程之美</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2018/06/21/【编程之美】链表面试题汇总版/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2018/06/21/【编程之美】链表面试题汇总版/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/2018/06/21/【编程之美】链表面试题汇总版/" class="leancloud_visitors" data-flag-title="【编程之美】链表面试题汇总版">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读量&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             <span></span>
			 </span>
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2,574
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  15
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h4 id="写在前面"><a href="#写在前面" class="headerlink" title="写在前面"></a>写在前面</h4><blockquote>
<p>对于不带头结点的单链表操作，是在面试中经常出现的，在此对于常见链表操作进行总结，<br>操作：有序链表合并、链表反转、链表排序、找倒数第K个节点、非头节点前插入data、删除非尾节点、约瑟夫环、带环链表环的大小等等</p>
</blockquote>
<hr>
<a id="more"></a>
<h4 id="function-h"><a href="#function-h" class="headerlink" title="function.h"></a><code>function.h</code></h4><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> __FUNCTION_H__</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> __FUNCTION_H__</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;stdlib.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;assert.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;malloc.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> DataType int</span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Node</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">	DataType data;</span><br><span class="line">	<span class="class"><span class="keyword">struct</span> <span class="title">Node</span>* _<span class="title">pNext</span>;</span></span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> <span class="title">Node</span> <span class="title">Node</span>;</span></span><br><span class="line"><span class="keyword">typedef</span> Node *pNode;</span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">InitNodeList</span><span class="params">(pNode *pHead)</span></span>;<span class="comment">//初始化</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">BuyNewNode</span><span class="params">(DataType data)</span></span>;<span class="comment">//新建节点</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">InsertNodeByFrontToTail</span><span class="params">(pNode *pHead, DataType data)</span></span>;<span class="comment">//头插法</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">PrintNodeProntToTail</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//正序打印</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">InserttNodeByTailToFront</span><span class="params">(pNode *pHead, DataType data)</span></span>;<span class="comment">//尾插法</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">ReceiveNodeList</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//反转链表—一般方法</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">ReceiveNodeList_DG</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//反转链表——递归实现</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">MeryTwoSortNodeChangeOneSortNode</span><span class="params">(pNode pHead1, pNode pHead2)</span></span>;<span class="comment">//合并两个有序单链表——一般方法</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">MeryTwoSortNodeChangeOneSortNode_DG</span><span class="params">(pNode pHead1, pNode pHead2)</span></span>;<span class="comment">//合并两个有序单链表——递归实现</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">BubbleSortNodeList</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//链表排序——冒泡法实现</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">SearchMIdNode</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//查找中间节点——快慢指针法</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">FindLastKNode</span><span class="params">(pNode pHead, <span class="keyword">int</span> key)</span></span>;<span class="comment">//找到倒数第K个节点</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">InsertNotIntoKHead</span><span class="params">(pNode pos, DataType data)</span></span>;<span class="comment">// 非头结点前插入data</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">FindDataInNodeList</span><span class="params">(pNode pHead, DataType k)</span></span>;<span class="comment">//寻找链表中data为K的节点</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">DeleteLastKNode</span><span class="params">(pNode pHead, <span class="keyword">int</span> key)</span></span>;<span class="comment">//删除倒数第K个节点</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">DeleteNotTailNode</span><span class="params">(pNode pos)</span></span>;<span class="comment">//删除单链表的非尾结点</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">GetCircleForJoseph</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//构造约瑟夫环</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">GetJosephCircle</span><span class="params">(pNode pHead, <span class="keyword">size_t</span> K)</span></span>;<span class="comment">//单链表实现约瑟夫环</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">GetCircleForList</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//构造带环链表</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">isHaveCircle</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//判断链表是否带环</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">GetCircleLength</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//求环的长度</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">GetCircleIntoNode</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//求环的入口点</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">pFrontNode</span><span class="params">(pNode pHead)</span></span>;<span class="comment">//返回链表第一个节点</span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">pTailNode</span><span class="params">(pNode pHead)</span></span>; <span class="comment">//返回链表最后一个节点</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">InsertNotHead</span><span class="params">(pNode pos, DataType data)</span></span>;<span class="comment">// 非头结点前插入data</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br></pre></td></tr></table></figure>
<h4 id="function-c"><a href="#function-c" class="headerlink" title="function.c"></a><code>function.c</code></h4><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">"function.h"</span></span></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">BuyNewNode</span><span class="params">(DataType data)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pTempNode = <span class="literal">NULL</span>;</span><br><span class="line">	pTempNode = (pNode)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(pNode));</span><br><span class="line">	<span class="keyword">if</span> (pTempNode)</span><br><span class="line">	&#123;</span><br><span class="line">		pTempNode-&gt;data = data;</span><br><span class="line">		pTempNode-&gt;_pNext = <span class="literal">NULL</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> pTempNode;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">InsertNodeByFrontToTail</span><span class="params">(pNode *pHead, DataType data)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pTemp = <span class="literal">NULL</span>;</span><br><span class="line">	<span class="keyword">if</span> (*pHead == <span class="literal">NULL</span>)</span><br><span class="line">		*pHead = BuyNewNode(data);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">else</span></span><br><span class="line">	&#123;</span><br><span class="line">		pTemp = BuyNewNode(data);</span><br><span class="line">		pTemp-&gt;_pNext = *pHead;</span><br><span class="line">		*pHead = pTemp;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">InserttNodeByTailToFront</span><span class="params">(pNode *pHead, DataType data)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pTest = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pCur = *pHead;</span><br><span class="line"></span><br><span class="line">	pTest = BuyNewNode(data);</span><br><span class="line">	<span class="keyword">if</span> (*pHead == <span class="literal">NULL</span>)</span><br><span class="line">		(*pHead) = pTest;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">else</span></span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">while</span> (<span class="literal">NULL</span> != pCur-&gt;_pNext)</span><br><span class="line">		&#123;</span><br><span class="line">			pCur = pCur-&gt;_pNext;</span><br><span class="line">		&#125;</span><br><span class="line">		pCur -&gt;_pNext = pTest;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">PrintNodeProntToTail</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="comment">//pNode pTemp = pHead;</span></span><br><span class="line">	<span class="keyword">if</span> (<span class="literal">NULL</span> == pHead)</span><br><span class="line">		<span class="keyword">return</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">while</span> (pHead != <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">"%d -&gt; "</span>, pHead-&gt;data);</span><br><span class="line">		pHead = pHead-&gt;_pNext;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"NULL"</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">ReceiveNodeList</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pTest = pHead;</span><br><span class="line">	<span class="comment">//pNode pNextNode = NULL;</span></span><br><span class="line">	pNode pPre = <span class="literal">NULL</span>;</span><br><span class="line">	<span class="comment">//pNode pReverse = NULL;</span></span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (pHead == <span class="literal">NULL</span> || pHead-&gt;_pNext == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> pHead;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">while</span> (pTest != <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		pNode pNextNode = pTest-&gt;_pNext;</span><br><span class="line">		pTest-&gt;_pNext = pPre;</span><br><span class="line">		pPre = pTest;</span><br><span class="line">		pTest = pNextNode;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> pPre;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">ReceiveNodeList_DG</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pNewNode = <span class="literal">NULL</span>;</span><br><span class="line">	<span class="keyword">if</span> (pHead == <span class="literal">NULL</span> || pHead-&gt;_pNext == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> pHead;</span><br><span class="line"></span><br><span class="line">	pNewNode = ReceiveNodeList_DG(pHead-&gt;_pNext);</span><br><span class="line"></span><br><span class="line">	pHead-&gt;_pNext-&gt;_pNext = pHead;                       <span class="comment">//翻转链表的指向</span></span><br><span class="line">	pHead-&gt;_pNext = <span class="literal">NULL</span>;                        <span class="comment">//记得赋值NULL，防止链表错乱</span></span><br><span class="line">	<span class="keyword">return</span> pNewNode;                          <span class="comment">//新链表头永远指向的是原链表的链尾</span></span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">MeryTwoSortNodeChangeOneSortNode</span><span class="params">(pNode pHead1, pNode pHead2)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pNewNode = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pTemp = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pNextNode = <span class="literal">NULL</span>;</span><br><span class="line">	<span class="keyword">unsigned</span> <span class="keyword">int</span> Node1Len = <span class="number">0</span>;</span><br><span class="line">	<span class="keyword">unsigned</span> <span class="keyword">int</span> Node2Len = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">while</span> (pHead1-&gt;_pNext != <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		++Node1Len;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">while</span> (pHead1-&gt;_pNext != <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		++Node2Len;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (Node1Len &lt; Node2Len)     <span class="comment">//长的链表为pHead1</span></span><br><span class="line">	&#123;</span><br><span class="line">		pTemp = pHead1;</span><br><span class="line">		pHead1 = pHead2;</span><br><span class="line">		pHead2 = pTemp;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">while</span> (pHead1 != <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">if</span> (pHead1-&gt;data &lt; pHead2-&gt;data)</span><br><span class="line">		&#123;</span><br><span class="line">			pNextNode = pHead1;</span><br><span class="line">			pHead1 = pHead1-&gt;_pNext;</span><br><span class="line">			pNextNode = pNextNode-&gt;_pNext;</span><br><span class="line">		&#125;</span><br><span class="line">		pNextNode = pHead2;</span><br><span class="line">		pHead2 = pHead2-&gt;_pNext;</span><br><span class="line">		pNextNode = pNextNode-&gt;_pNext;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">if</span> (pHead1 == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> pNewNode;</span><br><span class="line">	<span class="keyword">else</span></span><br><span class="line">	&#123;</span><br><span class="line">		pNextNode = pHead1;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> pNewNode;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">MeryTwoSortNodeChangeOneSortNode_DG</span><span class="params">(pNode pHead1, pNode pHead2)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pNewHead = <span class="literal">NULL</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (pHead1 == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> pHead2;</span><br><span class="line">	<span class="keyword">else</span> <span class="keyword">if</span> (pHead2 == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> pHead1;</span><br><span class="line">	<span class="keyword">else</span></span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">if</span> (pHead1-&gt;data &gt; pHead2-&gt;data)</span><br><span class="line">		&#123;</span><br><span class="line">			pNewHead = pHead2;</span><br><span class="line">			pNewHead-&gt;_pNext = MeryTwoSortNodeChangeOneSortNode_DG( pHead1, pHead2-&gt;_pNext);</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">else</span></span><br><span class="line">		&#123;</span><br><span class="line">			pNewHead = pHead1;</span><br><span class="line">			pNewHead-&gt;_pNext = MeryTwoSortNodeChangeOneSortNode_DG(pHead1-&gt;_pNext, pHead2);</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> pNewHead;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">BubbleSortNodeList</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> pTempNode = <span class="number">0</span>;</span><br><span class="line">	pNode pTail = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pPreCur = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pCur = <span class="literal">NULL</span>;</span><br><span class="line">	<span class="keyword">int</span> isFlag = <span class="number">1</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (pHead == <span class="literal">NULL</span> || pHead-&gt;_pNext == <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">return</span>;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">while</span> (pHead != pTail)</span><br><span class="line">	&#123;</span><br><span class="line">		isFlag = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">		pPreCur = pHead;</span><br><span class="line">		pCur = pHead-&gt;_pNext;</span><br><span class="line"></span><br><span class="line">		<span class="keyword">while</span> (pCur != pTail)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="keyword">if</span> (pCur-&gt;data &lt; pPreCur-&gt;data)</span><br><span class="line">			&#123;</span><br><span class="line">				pTempNode = pCur-&gt;data;</span><br><span class="line">				pCur-&gt;data = pPreCur-&gt;data;</span><br><span class="line">				pPreCur-&gt;data = pTempNode;</span><br><span class="line"></span><br><span class="line">				isFlag = <span class="number">1</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			pPreCur = pCur;</span><br><span class="line">			pCur = pCur-&gt;_pNext;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span> (!isFlag)</span><br><span class="line">			<span class="keyword">return</span>;</span><br><span class="line"></span><br><span class="line">		pTail = pPreCur;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">SearchMIdNode</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pFast = pHead;</span><br><span class="line">	pNode pSlow = pHead;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (pHead == <span class="literal">NULL</span> || pHead-&gt;_pNext == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">	<span class="keyword">while</span> (<span class="literal">NULL</span> != pFast &amp;&amp; <span class="literal">NULL</span> != pFast-&gt;_pNext)</span><br><span class="line">	&#123;</span><br><span class="line">		pSlow = pSlow-&gt;_pNext;</span><br><span class="line">		pFast = pFast-&gt;_pNext-&gt;_pNext;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> pSlow;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">FindLastKNode</span><span class="params">(pNode pHead, <span class="keyword">int</span> key)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pCur = pHead;</span><br><span class="line">	pNode pSlow = pHead;</span><br><span class="line">	pNode pFast = pHead;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (pHead == <span class="literal">NULL</span> )</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">while</span> (key--)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">if</span> (pFast == <span class="literal">NULL</span>)</span><br><span class="line">			<span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">		pFast = pFast-&gt;_pNext;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">while</span> (pFast != <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		pFast = pFast-&gt;_pNext;</span><br><span class="line">		pSlow = pSlow-&gt;_pNext;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> pSlow;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">DeleteLastKNode</span><span class="params">(pNode pHead, <span class="keyword">int</span> key)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pPosDelNode = FindLastKNode(pHead, key+<span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (pPosDelNode == pHead)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="built_in">free</span>(pPosDelNode);</span><br><span class="line">		<span class="keyword">return</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	pPosDelNode-&gt;_pNext = pPosDelNode-&gt;_pNext-&gt;_pNext;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">FindDataInNodeList</span><span class="params">(pNode pHead, DataType k)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pCur = pHead;</span><br><span class="line">	<span class="keyword">while</span> (pCur != <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">if</span> (pCur-&gt;data == k)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="keyword">return</span> pCur;</span><br><span class="line">		&#125;</span><br><span class="line">		pCur = pCur-&gt;_pNext;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">pFrontNode</span><span class="params">(pNode pHead)</span>       <span class="comment">//返回链表第一个节点</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pPcur = pHead;</span><br><span class="line">	<span class="keyword">if</span> (pHead == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">	<span class="keyword">return</span> pPcur;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">pTailNode</span><span class="params">(pNode pHead)</span>    <span class="comment">//返回链表最后一个节点</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pPcur = pHead;</span><br><span class="line">	<span class="keyword">if</span> (pHead == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">	<span class="keyword">while</span> (pPcur != <span class="literal">NULL</span> &amp;&amp; pPcur-&gt;_pNext != <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		pPcur = pPcur-&gt;_pNext;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> pPcur;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">GetCircleForList</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pTemp = <span class="literal">NULL</span>;</span><br><span class="line">	pTemp = FindDataInNodeList(pHead, <span class="number">9</span>);</span><br><span class="line">	pTemp-&gt;_pNext = FindDataInNodeList(pHead, <span class="number">7</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">isHaveCircle</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pSlowNode = pHead;</span><br><span class="line">	pNode pFastNode = pHead;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (pHead == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">while</span> (pFastNode != pSlowNode &amp;&amp; pFastNode-&gt;_pNext != <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		pFastNode = pFastNode-&gt;_pNext-&gt;_pNext;</span><br><span class="line">		pSlowNode = pSlowNode-&gt;_pNext;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> pSlowNode;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">GetCircleLength</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode MeetNode = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pCur = <span class="literal">NULL</span>;</span><br><span class="line">	<span class="keyword">size_t</span> count = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (isHaveCircle(pHead) == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">	MeetNode = isHaveCircle(pHead);</span><br><span class="line">	pCur = MeetNode-&gt;_pNext;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">while</span> (pCur != MeetNode)</span><br><span class="line">	&#123;</span><br><span class="line">		count++;</span><br><span class="line">		pCur = pCur-&gt;_pNext;</span><br><span class="line"></span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> count;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function">pNode <span class="title">GetCircleIntoNode</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pCur = pHead;</span><br><span class="line">	<span class="comment">//在判断带环问题时，返回了环中快慢指针的相遇点。</span></span><br><span class="line">	pNode pMeetNodeInCircle = <span class="literal">NULL</span>;</span><br><span class="line">	pMeetNodeInCircle = isHaveCircle(pHead);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">while</span> (pCur != pMeetNodeInCircle)</span><br><span class="line">	&#123;</span><br><span class="line">		pCur = pCur-&gt;_pNext;</span><br><span class="line">		pMeetNodeInCircle = pMeetNodeInCircle-&gt;_pNext;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> pMeetNodeInCircle;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">GetCircleForJoseph</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode front = <span class="literal">NULL</span>;</span><br><span class="line">	pNode tail = <span class="literal">NULL</span>;</span><br><span class="line">	front = pFrontNode(pHead);</span><br><span class="line">	tail = pTailNode(pHead);</span><br><span class="line"></span><br><span class="line">	tail-&gt;_pNext = front;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">GetJosephCircle</span><span class="params">(pNode pHead, <span class="keyword">size_t</span> K)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> count = K;</span><br><span class="line">	pNode pPreNode = pHead;</span><br><span class="line">	pNode pCurNode = <span class="literal">NULL</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (pHead == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span>;</span><br><span class="line">	<span class="keyword">while</span> (pPreNode-&gt;_pNext != pPreNode)</span><br><span class="line">	&#123;</span><br><span class="line">		count = K;</span><br><span class="line">		<span class="keyword">while</span> (--count)</span><br><span class="line">		&#123;</span><br><span class="line">			pCurNode = pPreNode;</span><br><span class="line">			pPreNode = pPreNode-&gt;_pNext;</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		pCurNode-&gt;_pNext = pPreNode-&gt;_pNext;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">"%d 号出去-&gt; "</span>, pPreNode-&gt;data);</span><br><span class="line">		<span class="comment">//free(pPreNode);</span></span><br><span class="line">		pPreNode = pPreNode-&gt;_pNext;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="comment">//return pPreNode;</span></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n最后留下的人是： %d \n\n"</span>, pPreNode-&gt;data);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">GetNodeListLength</span><span class="params">(pNode pHead)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> count = <span class="number">0</span>;</span><br><span class="line">	pNode pCur = pHead;</span><br><span class="line">	<span class="keyword">if</span> (pHead == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">	<span class="keyword">while</span> (pCur)</span><br><span class="line">	&#123;</span><br><span class="line">		count++;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> count;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">DeleteNotTailNode</span><span class="params">(pNode pos)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	assert(pos);</span><br><span class="line">	pNode pTempNode = <span class="literal">NULL</span>;</span><br><span class="line">	DataType temp = <span class="number">0</span>;</span><br><span class="line">	<span class="keyword">if</span> (pos == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span>;</span><br><span class="line">	<span class="keyword">else</span></span><br><span class="line">	&#123;</span><br><span class="line">		<span class="comment">//交换节点值</span></span><br><span class="line">		temp = pos-&gt;data;</span><br><span class="line">		pos-&gt;data = pos-&gt;_pNext-&gt;data;</span><br><span class="line">		pos-&gt;_pNext-&gt;data = temp;</span><br><span class="line"></span><br><span class="line">		pTempNode = pos-&gt;_pNext;</span><br><span class="line">		pos-&gt;_pNext = pTempNode-&gt;_pNext;</span><br><span class="line">		<span class="comment">//free(pTempNode);</span></span><br><span class="line">		pTempNode = <span class="literal">NULL</span>;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">InsertNotHead</span><span class="params">(pNode pos, DataType data)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pNewNode = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pCur = <span class="literal">NULL</span>;</span><br><span class="line">	DataType pTemp = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (pos == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span>;</span><br><span class="line"></span><br><span class="line">	pNewNode = BuyNewNode(data);</span><br><span class="line">	<span class="keyword">if</span> (pNewNode == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="keyword">return</span>;</span><br><span class="line"></span><br><span class="line">	pCur = pos;</span><br><span class="line">	pNewNode-&gt;_pNext = pCur-&gt;_pNext;</span><br><span class="line">	pCur-&gt;_pNext = pNewNode;</span><br><span class="line"></span><br><span class="line">	pTemp = pCur-&gt;data;</span><br><span class="line">	pCur-&gt;data = pNewNode-&gt;data;</span><br><span class="line">	pNewNode-&gt;data = pTemp;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="test-c"><a href="#test-c" class="headerlink" title="test.c"></a><code>test.c</code></h4><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">"function.h"</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">test</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	pNode pHead1 = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pHead2 = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pNewHead = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pHead3 = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pSortNode = <span class="literal">NULL</span>;</span><br><span class="line">	pNode LastKNum = <span class="number">0</span>;</span><br><span class="line">	pNode pReverseNode = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pR = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pHead4 = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pCirclieNode = <span class="literal">NULL</span>;</span><br><span class="line">	<span class="keyword">size_t</span> CircleLength = <span class="number">0</span>;</span><br><span class="line">	pNode pIntoCircleNode = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pHead5 = <span class="literal">NULL</span>;</span><br><span class="line">	pNode JueNode = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pHead6 = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pDelNode = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pInsertNode = <span class="literal">NULL</span>;</span><br><span class="line">	pNode pH = <span class="literal">NULL</span>;</span><br><span class="line"></span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead1, <span class="number">9</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead1, <span class="number">8</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead1, <span class="number">6</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead1, <span class="number">5</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead1, <span class="number">2</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead1, <span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">	PrintNodeProntToTail(pHead1);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n链表的反转、还原:\n"</span>);</span><br><span class="line">	pReverseNode = ReceiveNodeList(pHead1);     <span class="comment">//反转</span></span><br><span class="line">	PrintNodeProntToTail(pReverseNode);</span><br><span class="line"></span><br><span class="line">	pR = ReceiveNodeList_DG(pReverseNode);      <span class="comment">//反转</span></span><br><span class="line">	PrintNodeProntToTail(pR);</span><br><span class="line"></span><br><span class="line">	pHead1 = pR;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\npHead1: "</span>);</span><br><span class="line">	PrintNodeProntToTail(pHead1);          <span class="comment">//还原pHead1</span></span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"></span><br><span class="line">	InserttNodeByTailToFront(&amp;pHead2, <span class="number">2</span>);</span><br><span class="line">	InserttNodeByTailToFront(&amp;pHead2, <span class="number">3</span>);</span><br><span class="line">	InserttNodeByTailToFront(&amp;pHead2, <span class="number">4</span>);</span><br><span class="line">	InserttNodeByTailToFront(&amp;pHead2, <span class="number">5</span>);</span><br><span class="line">	InserttNodeByTailToFront(&amp;pHead2, <span class="number">6</span>);</span><br><span class="line">	InserttNodeByTailToFront(&amp;pHead2, <span class="number">7</span>);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"pHead2: "</span>);</span><br><span class="line">	PrintNodeProntToTail(pHead2);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n两个有序链表的合并:\n"</span>);</span><br><span class="line">	pNewHead = MeryTwoSortNodeChangeOneSortNode_DG(pHead1, pHead2);</span><br><span class="line">	PrintNodeProntToTail(pNewHead);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">	<span class="comment">//新建无序链表3</span></span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead3, <span class="number">9</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead3, <span class="number">4</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead3, <span class="number">5</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead3, <span class="number">7</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead3, <span class="number">4</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead3, <span class="number">0</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead3, <span class="number">3</span>);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\npHead3: "</span>);</span><br><span class="line">	PrintNodeProntToTail(pHead3);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n排序好的链表3："</span>);</span><br><span class="line">	BubbleSortNodeList(pHead3);</span><br><span class="line">	PrintNodeProntToTail(pHead3);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\npHead1中间节点：%d\n"</span>, (SearchMIdNode(pHead1)-&gt;data));</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\npNewHead中间节点：%d\n"</span>, (SearchMIdNode(pNewHead)-&gt;data));</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n查找倒数第K个节点: "</span>);</span><br><span class="line">	LastKNum = FindLastKNode(pNewHead, <span class="number">2</span>);</span><br><span class="line">	<span class="keyword">if</span> (LastKNum != <span class="literal">NULL</span>)</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">"%d\n"</span>, LastKNum-&gt;data);</span><br><span class="line">	<span class="keyword">else</span></span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">"没有找到\n"</span>);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n删除倒数第K个节点\n"</span>);</span><br><span class="line">	DeleteLastKNode(pNewHead, <span class="number">3</span>);</span><br><span class="line"></span><br><span class="line">	<span class="comment">//构造一个带环链表4</span></span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead4, <span class="number">9</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead4, <span class="number">8</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead4, <span class="number">6</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead4, <span class="number">5</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead4, <span class="number">2</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead4, <span class="number">1</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead4, <span class="number">3</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead4, <span class="number">0</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead4, <span class="number">7</span>);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n打印链表4：\n"</span>);</span><br><span class="line">	PrintNodeProntToTail(pHead4);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n构造带环链表\n"</span>);</span><br><span class="line">	GetCircleForList(pHead4);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"构造OK\n"</span>);</span><br><span class="line"></span><br><span class="line">	pCirclieNode = isHaveCircle(pHead4);</span><br><span class="line">	<span class="keyword">if</span> (pCirclieNode == <span class="literal">NULL</span>)</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">"不带环\n"</span>);</span><br><span class="line">	<span class="keyword">else</span></span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">"带环\n"</span>);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n求环的长度："</span>);</span><br><span class="line">	<span class="comment">//PrintNodeProntToTail(pHead4);</span></span><br><span class="line"></span><br><span class="line">	CircleLength = GetCircleLength(pHead4);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"%d"</span>, CircleLength);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n求环的入口："</span>);</span><br><span class="line">	pIntoCircleNode = GetCircleIntoNode(pHead4);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"%d\n"</span>, pIntoCircleNode-&gt;data);</span><br><span class="line"></span><br><span class="line">	<span class="comment">//构造一个链表，pHead5：    头插法构造单链表</span></span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead5, <span class="number">9</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead5, <span class="number">8</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead5, <span class="number">7</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead5, <span class="number">6</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead5, <span class="number">5</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead5, <span class="number">4</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead5, <span class="number">3</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead5, <span class="number">2</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead5, <span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n约瑟夫环问题:\n"</span>);</span><br><span class="line">	<span class="comment">//构造环</span></span><br><span class="line">	GetCircleForJoseph(pHead5);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"构造OK\n"</span>);</span><br><span class="line"></span><br><span class="line">	<span class="comment">//PrintNodeProntToTail(pHead5);</span></span><br><span class="line"></span><br><span class="line">	<span class="comment">//约瑟夫环</span></span><br><span class="line">	GetJosephCircle(pHead5, <span class="number">4</span>);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"构造链表6\n"</span>);</span><br><span class="line"></span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead6, <span class="number">6</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead6, <span class="number">5</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead6, <span class="number">4</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead6, <span class="number">3</span>);</span><br><span class="line">	InsertNodeByFrontToTail(&amp;pHead6, <span class="number">2</span>);</span><br><span class="line"></span><br><span class="line">	PrintNodeProntToTail(pHead6);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n删除倒数第 3 个节点后，链表为：\n"</span>);</span><br><span class="line">	DeleteLastKNode(pHead6, <span class="number">3</span>);</span><br><span class="line"></span><br><span class="line">	PrintNodeProntToTail(pHead6);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line"></span><br><span class="line">	PrintNodeProntToTail(pHead6);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"删除非尾节点 3 :\n"</span>);</span><br><span class="line">	pDelNode = FindDataInNodeList(pHead6, <span class="number">3</span>);</span><br><span class="line">	DeleteNotTailNode(pDelNode);</span><br><span class="line">	PrintNodeProntToTail(pHead6);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n非头节点 5 前的插入:\n"</span>);</span><br><span class="line">	PrintNodeProntToTail(pHead6);</span><br><span class="line"></span><br><span class="line">	pInsertNode = FindDataInNodeList(pHead6, <span class="number">5</span>);</span><br><span class="line"></span><br><span class="line">	InsertNotHead(pInsertNode, <span class="number">99</span>);</span><br><span class="line">	PrintNodeProntToTail(pHead6);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"\n"</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	test();</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

      
    </div>
    
    
    
	
	
	
	<div>
  
    <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>


  
</div>
	
	

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/img/money.png" alt="何进鸿 微信支付"/>
        <p>微信支付</p>
      </div>
    

    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/链表面试题/" rel="tag"><i class="fa fa-tag"></i> 链表面试题</a>
          
            <a href="/tags/编程之美/" rel="tag"><i class="fa fa-tag"></i> 编程之美</a>
          
            <a href="/tags/无头单链表/" rel="tag"><i class="fa fa-tag"></i> 无头单链表</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/06/17/C语言实现一般通讯录/" rel="next" title="C语言版通讯录">
                <i class="fa fa-chevron-left"></i> C语言版通讯录
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/07/14/长连接与短连接/" rel="prev" title="长连接与短连接">
                长连接与短连接 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="http://7xrvas.com1.z0.glb.clouddn.com/16-4-6/38502140.jpg"
                alt="何进鸿" />
            
              <p class="site-author-name" itemprop="name">何进鸿</p>
              <p class="site-description motion-element" itemprop="description">技术汇总、趣事速记</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">7</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">5</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">24</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://blog.csdn.net/m0_37925202" target="_blank" title="CSDN">
                      
                        <i class="fa fa-fw fa-skype"></i>CSDN</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:askunix@163.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://weibo.com/5729154534/profile?topnav=1&wvr=6" target="_blank" title="Weibo">
                      
                        <i class="fa fa-fw fa-weibo"></i>Weibo</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://juejin.im/timeline" target="_blank" title="JueJin">
                      
                        <i class="fa fa-fw fa-magnet"></i>JueJin</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://twitter.com/yourname" target="_blank" title="Twitter">
                      
                        <i class="fa fa-fw fa-twitter"></i>Twitter</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://youtube.com/yourname" target="_blank" title="YouTube">
                      
                        <i class="fa fa-fw fa-youtube"></i>YouTube</a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-inline">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                推荐阅读
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.runoob.com/" title="RUNOOB.COM" target="_blank">RUNOOB.COM</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.liaoxuefeng.com/category/0013738748415562fee26e070fa4664ad926c8e30146c67000" title="寥雪峰的官方网站" target="_blank">寥雪峰的官方网站</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://blog.csdn.net/m0_37925202" title="say_askunix的博客" target="_blank">say_askunix的博客</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://iissnan.com/progit/" title="Pro Git简体中文版" target="_blank">Pro Git简体中文版</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.bootcss.com/p/font-awesome/#" title="Font Awesome" target="_blank">Font Awesome</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://ju.outofmemory.cn/" title="聚客·汇聚优秀技术" target="_blank">聚客·汇聚优秀技术</a>
                  </li>
                
              </ul>
            </div>
          

		  
		  
		  
		  
		<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=528478901&auto=0&height=66"></iframe>  
		  
		  
		  
		  
		  
		  
		  
		  
		  
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#写在前面"><span class="nav-number">1.</span> <span class="nav-text">写在前面</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#function-h"><span class="nav-number">2.</span> <span class="nav-text">function.h</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#function-c"><span class="nav-number">3.</span> <span class="nav-text">function.c</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#test-c"><span class="nav-number">4.</span> <span class="nav-text">test.c</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        

<div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">何进鸿</span>

  
</div>



<!--
  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>

-->







<div class="theme-info">
  <div class="powered-by"></div>
   <i class="fa fa-pencil"></i>
  <span class="post-count">全站共13.1k字</span>
</div>






|| 梦想没了行动  只会变成空想 || 建议PC端浏览
 
 



 
 
 <div>
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

本站总访问量 <span id="busuanzi_value_site_pv"></span> 次&nbsp&nbsp&nbsp
本站访客数<span id="busuanzi_value_site_uv"></span>人次



</div>

 
 
 
 
 
<!--
<div class="powered-by"></div>
	
    <span class="site-uv">
      <i class="fa fa-eye"></i>
	  
      全站访客<span class="busuanzi-value" id="busuanzi_value_site_pv"></span> 次</span>

-->



<!-- 新增访客统计代码 -->
<!--
<div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-balance-scale"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">何进鸿</span>
</div>


<div class="busuanzi-count">
    <script async="" src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="site-uv">
      <i class="fa fa-user"></i>
      访问用户： <span class="busuanzi-value" id="busuanzi_value_site_uv"></span> 人
    </span>
	
-->
	
<!--	
    <div class="powered-by"></div>
	
    <span class="site-uv">
      <i class="fa fa-eye"></i>
	  
      全站访客： <span class="busuanzi-value" id="busuanzi_value_site_pv"></span> 次</span>
-->	
	

	
<!-- 博客字数统计 
    <span class="site-pv">
      <i class="fa fa-pencil"></i>
      全站共： <span class="post-count">13.1k</span> 字
    </span>
</div>
-->
<!-- 新增访客统计代码 END-->



<section class="footer-time">
    <span class="footer__copyright">
    <div>
    <span id="span_dt_dt"> </span>
    <script language="javascript">
      function show_date_time(){
        window.setTimeout("show_date_time()", 1000);
        BirthDay=new Date("6/25/2018 10:56:12");
        today=new Date();
        timeold=(today.getTime()-BirthDay.getTime());
        sectimeold=timeold/1000
        secondsold=Math.floor(sectimeold);
        msPerDay=24*60*60*1000
        e_daysold=timeold/msPerDay
        daysold=Math.floor(e_daysold);
        e_hrsold=(e_daysold-daysold)*24;
        hrsold=Math.floor(e_hrsold);
        e_minsold=(e_hrsold-hrsold)*60;
        minsold=Math.floor((e_hrsold-hrsold)*60);
        seconds=Math.floor((e_minsold-minsold)*60);
        span_dt_dt.innerHTML="Askunix's Blog已运行："+daysold+" 天 "+hrsold+" 小时 "+minsold+" 分 "+seconds+" 秒";
      }
      show_date_time();
    </script>
    </div>
    <script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
</section>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: '8rbOzLF6j6mMuBvuRBuOLq5O-gzGzoHsz',
        appKey: '4PbGi909IHAsoIarzl5ryvrA',
        placeholder: '来啊，快活啊~',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("O8NSjM7KSnPoDYSlBbd2lqfX-gzGzoHsz", "19z7omdx78LwKxzBHxrOskhe");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  

  

  

  

  
  
  <!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/love.js"></script>
  
  

  
  
  
 
<script type="text/javascript"
color="0,0,255" opacity='0.7' zIndex="-2" count="99" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>

  
  
  
  
  
</body>
</html>
